<?
/* @author Udo Schroeter <udo.schroeter@gmail.com>
 * @license dual license: LGPL / commercial use license
 */ 

  function file_list($dir)
  {
    $result = array();
    if(is_dir($dir))
    {
      if($handle = opendir($dir))
      {
        while(($file = readdir($handle)) !== false)
        {
          if(substr($file, 0, 1)!='.' && $file != "Thumbs.db"/*pesky windows, images..*/)
          {
            $result[$dir.$file] = $file;
          }
        }
        closedir($handle);
      }
    }
    return($result);
  }
  
  // append any string to the given file
  function WriteToFile($filename, $content)
  {
    if (is_array($content)) $content = getArrayDump($content);
    $open = fopen($filename, 'a+');
    fwrite($open, $content);
    fclose($open);
    chmod($filename, 0777);
  }

  // standard logging function (please log only to the log/ folder)
  // - error logs should begin with the prefix "err."
  // - warning logs should begin with the prefix "warn."
  // - notice logs should begin with the prefix "notice."
  function logToFile($filename, $content, $clearfile = false)
  {
    global $logHeader;
    if ($clearfile) @unlink($filename);
    if (is_array($content)) $content = getArrayDump($content);
    @WriteToFile($filename,
      '<log exec="'.profiler_getTime().'" '.$logHeader.' client="'.
      $_SERVER['REMOTE_ADDR'].'" timestamp="'.date('Y-m-d H:i:s').'" '.
      ">\r\n".
      '  '.trim($content)."\r\n".
      "</log>\r\n\r\n");
  }


?>